<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      /*  .box {
        width: 400px;
        height: 400px;
        background-color: yellow;
        position: relative;
      }
      .minibox {
        width: 100px;
        height: 100px;
        background-color: red;
        position: absolute;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        margin:  auto;
      } */
    </style>
  </head>
  <body>
    <script>
      //回文数 正反读都是一样的
      function fn(x) {
        if(x< 0 || (x%10===0 && x != 0) ) return false  //负数  末尾为0 且不等于o
        let a = 0
        while(x>a){
          a = a*10 + x %10
          x = parseInt(x/10)
        }
        return x ===a  || x===parseInt(a/10)
      }
    console.log(  fn(242));
    </script>
  </body>
</html>
